package cn.mw.cmdb.param;

import cn.mw.cmdb.util.GetI18NMessageUtils;
import cn.mw.microMonitorCommon.util.I18NMessageUtils;

public enum TableIdSCBankEnum {
    model("model", "资产分类", true)
    , org("org", "机构", true)
    , location("location", "办公楼名称", true)
    ,assetType("assetType", "设备类型", true)
    , instance("instance", "实例", false)
    , property("property", "属性", false)
    , group("group", "模型分组", false)
    , customInstance("customInstance", "自定义实例", false)
    , commonInstance("commonInstance", "通用实例", false)
    , custom("custom", "自定义分类", false)
    ,status("status", "资产状态", false);
    private String code;
    private String name;

    //是否在下拉框中显示
    private boolean showInDropDown;

    TableIdSCBankEnum(String code, String name, boolean showInDropDown) {
        this.code = code;
        this.name = name;
        this.showInDropDown = showInDropDown;
    }

    public static TableIdSCBankEnum getTableIdEnum(String code) {
        for (TableIdSCBankEnum tableIdEnum : TableIdSCBankEnum.values()) {
            if (tableIdEnum.getCode().equals(code)) {
                return tableIdEnum;
            }
        }
        return custom;
    }

    public String getCode() {
        return code;
    }

    public String getName() {
        I18NMessageUtils bean = GetI18NMessageUtils.getI18NMessageUtils();
        if (name.contains(bean.getMessage("cmdb-enums-replace-source"))){
            return name.replace(bean.getMessage("cmdb-enums-replace-source"),
                    bean.getMessage("cmdb-enums-replace-target"));
        }
        return name;
    }

    public boolean isShowInDropDown() {
        return showInDropDown;
    }
}
